/*
 * @Author: 李灿
 * @Date: 2021-07-29 10:14:08
 * @LastEditTime: 2021-07-29 10:14:29
 * @Description:求元素下出现最多的标签
 * @FilePath: /javascript/meetings/0.总结/22.js
 */
const tags = document.getElementById("app").children;
const obj = {};

for (let i = 0; i < tags.length; i++) {
  if (!obj[tags[i]]) {
    obj[tags[i]] = { key: tags[i], value: 0 };
  } else {
    obj[tags[i]].value = obj[tags[i]].value + 1;
  }
}

const compare = (a, b) => {
  return a.value - b.value;
};

const result = Object.keys(obj)
  .map((item) => obj[item])
  .sort(compare);
console.log(result[result.length - 1].key);
